//
//  HZJBaseTabViewController.swift
//  HZJNavigationView
//
//  Created by HZJ on 2017/3/14.
//  Copyright © 2017年 HZJ. All rights reserved.
//

import UIKit

class HZJBaseTabViewController: HZJBaseViewController,UITableViewDelegate,UITableViewDataSource {
    
    lazy var tabView:UITableView = {
        let tab = UITableView()
        tab.delegate = self
        tab.dataSource = self
        return tab
    }()
    override func viewDidLoad() {
        super.viewDidLoad()
        
        title = "HZJBaseTabViewController"
        self.view.insertSubview(tabView, belowSubview: myNavigationBar)
        tabView.frame = self.view.frame

        tabView.separatorStyle = .none
        tabView.register(UITableViewCell.self, forCellReuseIdentifier: "CELLID")
        self.automaticallyAdjustsScrollViewInsets = false
    }

    override func viewWillAppear(_ animated: Bool) {
        //设置滚动的范围
        let top = myNavigationBar.isHidden ? 0 : myNavigationBar.frame.maxY
        tabView.contentInset = UIEdgeInsets(top: top, left: 0, bottom: 0, right: 0)
    }
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    func numberOfSections(in tableView: UITableView) -> Int {
        return 1
    }
    
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 15
    }
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "CELLID", for: indexPath)
        cell.backgroundColor = UIColor.random
        return cell
    }
    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        return 88
    }
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        tableView.deselectRow(at: indexPath, animated: true)
    }
    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
